/*
 * @Author: jiu yin
 * @Date: 2023-05-17 14:21:09
 * @LastEditTime: 2023-05-17 17:39:17
 * @LastEditors: jiu yin zhen jing
 * @FilePath: \init-admin\src\stores\common.js
 * jiu
 */
import { ref, computed, reactive, watchEffect } from 'vue'
import { getSession, setSession } from "@/utils"

import { defineStore } from 'pinia'


export const useCommon = defineStore('common', () => {
    let obj={
        i18n_lang: 'zh',
    }
    const common = reactive(getSession('common') || obj)
    const deepCommon = computed(() => common)

    watchEffect(() => {
        setSession('common', deepCommon.value)
    })

    function set(key, value) {
        common[key] = value
    }
    function get(key, value) {
        return common[key]
    }


    return { set, get, deepCommon }
})
